# Definition for singly-linked list.
class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next

head=ListNode(1,None)
head.next=ListNode(1,None)
head.next.next=ListNode(2,None)
# head.next.next.next=ListNode(3,None)
# head.next.next.next.next=ListNode(3,None)
def deleteDuplicates(head):
    if head==None or (head!=None and head.next==None):
        #没有结点或者只有一个节点
        return head
    headProcess = head
    headProcessNext=head.next
    while headProcess!=None and headProcessNext!=None:
        if headProcess.val==headProcessNext.val:
            #重复的元素
            #headProcess的下一个结点发生变化
            headProcess.next=headProcessNext.next
            #在前面的对比指针发生变化
            headProcessNext=headProcessNext.next
        else:
            #不是重复元素的情况
            headProcess=headProcessNext
            headProcessNext=headProcessNext.next
    headProcess=head
    while headProcess:
        print(headProcess.val)
        headProcess=headProcess.next
print(deleteDuplicates(head))